package dto

import (
	"jtvss/api/operation/model"

	"jtvss/pkg/orm"
)

// Where 分页
type Where struct {
	orm.DbPage
	DeviceNo     string `form.:"deviceNo"`
	OrganizeID   *int   `form.:"organizeId"` // 每页数
	OrganizeGUID string `form.:"-"`
}

// DbModelWhere
func (o *Where) DbModelWhere(v interface{}, handlers ...func(*orm.DbWhere)) *orm.DbWhere {
	w := o.DbWhere()
	switch v.(type) {
	case *model.Vehicle:
		w.Equal("DeviceNo", o.DeviceNo)
		w.Equal("OrganizeID", o.OrganizeID)
		w.Equal("OrganizeGUID", o.OrganizeGUID)
	}
	for _, h := range handlers {
		h(w)
	}
	return w.Model(v)
}
